package com.xvyy.tingshu.album.rpc;


import com.xvyy.tingshu.album.service.AlbumInfoService;
import com.xvyy.tingshu.album.service.BaseCategoryService;
import com.xvyy.tingshu.album.service.TrackInfoService;
import com.xvyy.tingshu.common.result.Result;
import com.xvyy.tingshu.model.album.AlbumInfo;
import com.xvyy.tingshu.model.album.BaseCategory3;
import com.xvyy.tingshu.model.album.BaseCategoryView;
import com.xvyy.tingshu.model.album.TrackInfo;
import com.xvyy.tingshu.vo.album.AlbumStatVo;
import com.xvyy.tingshu.vo.album.TrackListVo;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * ClassName: AlbumInfoRpcController
 * Package: com.xvyy.tingshu.search.rpc
 *
 * @Description:
 * @Author: xvyy
 * @Create: 2025/1/19 - 14:50
 * @Version: v1.0
 */
@RestController
@RequestMapping("/api/inner/albumInfo")
public class AlbumInfoRpcController {

    @Autowired
    private AlbumInfoService albumInfoService;
    @Autowired
    private BaseCategoryService baseCategoryService;
    @Autowired
    private TrackInfoService trackInfoService;


    @GetMapping("/getAlbumInfo/{albumId}")
    @Operation(summary = "根据专辑albumId获取专辑信息")
    Result<AlbumInfo> getAlbumInfo(@PathVariable Long albumId) {

        AlbumInfo albumInfo = albumInfoService.getAlbumInfo(albumId);
        return Result.ok(albumInfo);
    }

    @GetMapping("/getAlbumInfoCategory/{albumId}")
    @Operation(summary = "根据专辑albumId获取专辑分类信息")
    Result<BaseCategoryView> getAlbumInfoCategory(@PathVariable(value = "albumId") Long albumId) {

        BaseCategoryView baseCategoryView = baseCategoryService.getAlbumInfoCategory(albumId);
        return Result.ok(baseCategoryView);
    }


    @GetMapping("/getAlbumInfoStat/{albumId}")
    @Operation(summary = "根据专辑albumId获取专辑统计信息")
    Result<AlbumStatVo> getAlbumInfoStat(@PathVariable(value = "albumId") Long albumId) {
        AlbumStatVo albumStatVo = albumInfoService.getAlbumInfoStat(albumId);
        return Result.ok(albumStatVo);
    }

    @GetMapping("/getC1Id7TopBaseCategory3List/{c1Id}")
    @Operation(summary = "根据一级分类c1Id获取7个置顶的三级分类对象")
    Result<List<BaseCategory3>> getC1Id7TopBaseCategory3List(@PathVariable(value = "c1Id") Long c1Id) {
        List<BaseCategory3> baseCategory3List = baseCategoryService.getC1Id7TopBaseCategory3List(c1Id);
        return Result.ok(baseCategory3List);
    }

    @GetMapping("/getCategory1IdList")
    @Operation(summary = "获取所有一级分类的id集合")
    Result<List<Long>> getCategory1IdList() {
        List<Long> c1IdList = baseCategoryService.getCategory1IdList();
        return Result.ok(c1IdList);
    }

    @PostMapping("/trackListVo")
    @Operation(summary = "获取收藏的声音集合")
    Result<List<TrackListVo>> getTrackListVo(@RequestBody List<Long> collectTrackIdList) {
        List<TrackListVo> trackListVoList = albumInfoService.getTrackListVo(collectTrackIdList);
        return Result.ok(trackListVoList);
    }

    @GetMapping("/getAlbumInfoIdList")
    @Operation(summary = "获取专辑id集合")
    Result<List<Long>> getAlbumInfoIdList() {
        List<Long> albumIdList = albumInfoService.getAlbumInfoIdList();
        return Result.ok(albumIdList);
    }

    @GetMapping("/getTrackInfoById/{trackId}")
    @Operation(summary = "根据声音trackId获取声音信息")
    Result<TrackInfo> getTrackInfoById(@PathVariable(value = "trackId") Long trackId) {
        return Result.ok(trackInfoService.getById(trackId));
    }

    @GetMapping("/getPaidTrackAndFilterCanPayTrack/{albumId}/{userId}/{trackCount}/{trackId}")
    @Operation(summary = "判断是否在支付中，查询声音并过滤购买过的声音列表")
    Result<List> getPaidTrackAndFilterCanPayTrack(
            @PathVariable(value = "albumId") Long albumId,
            @PathVariable(value = "userId") Long userId,
            @PathVariable(value = "trackCount") Integer trackCount,
            @PathVariable(value = "trackId") Long trackId){
        return trackInfoService.getPaidTrackAndFilterCanPayTrack(albumId,userId,trackCount,trackId);
    }
}
